<?php
/* @var $model Ad */
/* @var $this AdController */
?>
<?php
$this->breadcrumbs = array(
    'Eblast' => array('all_eblast'),
    'Manage Eblast',
);
?>
<div class="box">
    <header>
        <h5>Manage Eblast</h5>	

    </header>
    <div class="body">
	<?php
	$this->widget('bootstrap.widgets.TbGridView', array(
	    'id' => 'eblast-grid',
	    'dataProvider' => $model->search(),
	    'filter' => $model,
	    'columns' => array(
		array(
		    'header' => 'Username',
		    'type' => 'raw',
		    'value' => function($data) {
			return "<a href='" . BACKEND_SITE_URL . "user/member/update?id=" . $data->ad->user->user_id . "'>" . h($data->ad->user->username, 10) . "</a>";
		    }
		),
		array(
		    'header' => 'Belong to post',
		    'type' => 'raw',
		    'value' => function($data) {
			if ($data->ad) {
			    return "<a href='" . BACKEND_SITE_URL . "adv/ad/update?id=" . $data->ad_id . "'>" . h($data->ad->content, 10) . "</a>";
			}
		    }
		),
		array(
		    'header' => 'Pick time',
		    'name' => 'start_date',
		    'type' => 'date',
		    'filter' => false
		),
		array(
		    'name' => 'main_category',
		    'value' => '$data->mainCategory->name',
		    'filter' => $aCats
		),
		array(
		    'name' => 'status',
		    'value' => '$data->getStatusText()',
		    'filter' => Eblast::getAllStatus()
		),
		array(
		    'header' => 'Attachment',
		    'type' => 'raw',
		    'value' => function($data) {
			return $data->getFileUrl();
		    }
		),
		array(
		    'header' => 'Approve',
		    'type' => 'raw',
		    'value' => function($data) {
			if ($data->status != Eblast::STATUS_APPROVE) {
			    return '<a href="' . BACKEND_SITE_URL . 'adv/ad/approve_eblast?id=' . $data->id . '">Approve</a>';
			}
		    }
		),
		array(
		    'class' => 'bootstrap.widgets.TbButtonColumn',
		    'template' => '{delete}',
		    'buttons' => array(
			'delete' => array(
			    'url' => 'Yii::app()->controller->createUrl("ad/delete_eblast", array("id"=>$data->id))',
			)
		    ),
		),
	    ),
	));
	?>
    </div>
</div>